package clm.tail;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ConsoleOutputThread extends Thread {

	@Override
	public void run() {
		SimpleDateFormat sdf = new SimpleDateFormat("[MM/dd/yyyy HH:mm:ss.SSS]");
		System.out.println(sdf.format(new Date()) + " - Output thread started.");
		
		boolean theBool = true;
		LogEntryDTO lineDTO;
		try {
			Thread.sleep(2000L);
			while(theBool){			
				while ((lineDTO = GlobalQueues.linePriorityQueue.poll()) != null) {
					System.out.println(lineDTO.getFileReference() + " - " + lineDTO.getLineText());
				}
				Thread.sleep(2000L);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
			return;
		}
		System.out.println(sdf.format(new Date()) + " - Output thread finished.");
	}

}
